export interface ShowLoadingParam {
  title?: string
}

export interface ShowToastParam extends ShowLoadingParam {
  icon?: 'success' | 'loading' | 'none' | undefined
  duration?: number
  callback?: Function
}

export function showToast({ title = '操作成功', icon = 'success', duration = 1500, callback }: ShowToastParam = {}) {
  uni.showToast({
    title: title,
    icon,
    mask: true,
    duration
  })
  setTimeout(() => {
    callback && callback()
  }, duration)
}

export function showLoading({ title = '请求中' }: ShowLoadingParam = {}) {
  uni.showLoading({
    title,
    mask: true
  })
}
